<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="x">
<span  id="btn" style="border: 1px solid #c0c0c0">xxx</span>
<script>
    var r = Math.round(Math.random()*13);
    var btnObj = document.getElementById('btn');
    btnObj.onclick = function () {
        console.log(r);
        var xObj = document.getElementById('x');
        var x = xObj.value;
        if (x == r) {

            alert('你猜对了');
        }
    }
</script>

</body>
</html>